import java.util.LinkedList;
import java.util.Queue;

public class Solution933 {

    Queue<Integer> queue=new LinkedList<>();

    public Solution933() {

    }

    public int ping(int t) {
        queue.offer(t);
        while (queue.peek()<t-3000){
            queue.poll();
        }
        return queue.size();
    }

    public static void main(String[] args) {
        Solution933 solution933=new Solution933();
        System.out.println(solution933.ping(1));
        System.out.println(solution933.ping(100));
        System.out.println(solution933.ping(3001));
        System.out.println(solution933.ping(3002));
    }
}
